﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class GameCalendar : MonoBehaviour
{
    
    public int StartYear;
    public int StartMonth;
    public int StartDay;
    public Text dateText;

    private double nextTime = 0;//下一次发生变化的时间点
    private double dTime = 0.01;//设置发生变化的时间间隔，下称时间间隔
    private bool isGoingOn = false;

    // Start is called before the first frame update

    void addDay()
    {
        if (StartDay == 30)
        {
            if (StartMonth == 12)
            {
                StartYear++;
                StartMonth = 0;
            }
            StartDay = 0;
            StartMonth++;
        }
        StartDay++;
    }

    public void Stop_Button()
    {
        isGoingOn = false;
    }

    public void Button_1()
    {
        isGoingOn = true;
        dTime = 0.3;
    }

    public void Button_2()
    {
        isGoingOn = true;
        dTime = 0.1;
    }

    public void Button_3()
    {
        isGoingOn = true;
        dTime = 0.05;
    }

    // Update is called once per frame
    void Update()
    {
        if (isGoingOn && Time.time > nextTime)
        {
            addDay();
            nextTime = Time.time+dTime;
        }

        dateText.text = String.Format("{0}/{1}/{2}", StartYear, StartMonth, StartDay);
    }
}